class Solution:
    def mergeKLists(self, lists: List[ListNode]) -> ListNode:
        if not lists:
            return None
        nums = []

        for i in lists:
            while i:
                nums.append(i.val)
                i = i.next

        if not nums:
            return None

        nums.sort()
        dummy = ListNode(0)
        p = dummy
        for i in nums:
            p.next = ListNode(i)
            p = p.next

        return dummy.next